package com.common.db;

import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MybatisDBUtil {

	private static SqlSessionFactory sqlSessionFactory;
	private static Reader reader;

	static {
		try {
			reader = Resources.getResourceAsReader("rm-sql-map-config.xml");
			sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
			
//			  ���Դ��ʽ����
//			 DataSource ds = ���� // ��ȡһ�� DataSource 
//			 TransactionFactory txFactory = new JdbcTransactionFactory(); 
//			 Environment env = new Environment("demo", txFactory, ds); 
//			 Configuration cfg = new Configuration(env); 
//			 cfg.addMapper(UserInfoMapper.class); 
//			 SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(cfg);
		
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static SqlSessionFactory getSessionFactory() {

		return sqlSessionFactory;
	}

	public static void main(String[] argss ){
		System.out.println("------"+MybatisDBUtil.getSessionFactory());
	}
}